home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adatutor / spacemon / displayb.src < prev    next >
Text File  |  1996-01-30  |  6KB  |  172 lines

  1. with Spacecraft_Sensor_Interface; use Spacecraft_Sensor_Interface;
  2. with Console; use Console;
  3. with Types; use Types;
  4. with TEXT_IO; use TEXT_IO;
  5.     
  6. package body CRT_Output is
  7.     
  8.     procedure Display(arg: in PRESSURE_ARRAY) is
  9.  
  10.     Range_per_equal: constant PRESSURE := 5.0;
  11.     Equal_signs: INTEGER;
  12.     i: SPACECRAFT_SECTION;
  13.     package SPACECRAFT_SECTION_IO is new ENUMERATION_IO(SPACECRAFT_SECTION);
  14.     use SPACECRAFT_SECTION_IO;
  15.     begin    
  16.         Console.Set_Terminal (VT100);
  17.         Console.Enable_Output;
  18.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  19.         Console.Erase_Display;
  20.         Console.New_Line;
  21.         Console.Put_Line("Pressure            min         max");
  22.         Console.Put_Line("  p.s.i              |           |");
  23.         Console.Put_Line("                     V           V");
  24.  
  25.         for i in SPACECRAFT_SECTION'FIRST .. SPACECRAFT_SECTION'LAST loop
  26.  
  27.             if arg(i).in_range then
  28.                 Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  29.             else
  30.                 Console.Set_Rendition(REVERSE_VIDEO);
  31.                 Console.Put(ASCII.BEL);
  32.             end if;                            
  33.     
  34.             Equal_signs := INTEGER(arg(i).value / Range_per_equal + 1.0);
  35.             -- may use Exception here if out of range on Equal_signs    
  36.             -- Console.Put("                ");
  37.             -- SPACECRAFT_SECTION_IO.Put(i);
  38.             if i = BRIDGE then Console.Put("BRIDGE           ");end if;
  39.             if i = AUXILIARY_BRIDGE then Console.Put("AUXILARY BRIDGE  ");end if;
  40.             if i = CREW_QUARTERS then Console.Put("CREW_QUARTERS    ");end if;
  41.             if i = GALLEY then Console.Put("GALLEY           ");end if;
  42.             if i = LAB1 then Console.Put("LAB 1            ");end if;
  43.             if i = LAB2 then Console.Put("LAB 2            ");end if;
  44.             if i = LAB3 then Console.Put("LAB 3            ");end if;
  45.             if i = AIRLOCK1 then Console.Put("AIRLOCK 1        ");end if;
  46.             if i = AIRLOCK2 then Console.Put("AIRLOCK 2        ");end if;
  47.             if i = EXPERIMENT_BAY then Console.Put("EXPERIMENT BAY   ");end if;
  48.  
  49.             for j in 1 .. Equal_signs loop 
  50.                 Console.Put('=');
  51.             end loop;
  52.             for j in 1 .. 50-Equal_signs loop
  53.                 Console.Put(' ');
  54.             end loop;
  55.             Console.Put(FLOAT(arg(i).value),4,2,OUTPUT_FULL_NUMBER,'*');
  56.  
  57.             Console.New_Line;
  58.         end loop;
  59.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);    
  60.     end Display;
  61.  
  62.     procedure Display(arg: in RADIATION_ARRAY) is
  63.  
  64.     Range_per_equal: constant RADIATION_LEVEL := 25.0;
  65.     Equal_signs : INTEGER;
  66.     package SPACECRAFT_SECTION_IO is new ENUMERATION_IO(SPACECRAFT_SECTION);
  67.     use SPACECRAFT_SECTION_IO;
  68.     
  69.     begin
  70.         Console.Set_Terminal (VT100);
  71.         Console.Enable_Output;
  72.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  73.         for j in 1 .. 50 loop
  74.             Console.Put('*');
  75.         end loop;
  76.         Console.New_Line;
  77.         Console.Put_Line("Radiation       min              max");
  78.         Console.Put_Line("Roentgens        |                |");
  79.         Console.Put_Line("                 V                V");
  80.  
  81.         for i in SPACECRAFT_SECTION'FIRST .. SPACECRAFT_SECTION'LAST loop
  82.  
  83.             if arg(i).in_range then
  84.                 Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  85.             else
  86.                 Console.Set_Rendition(REVERSE_VIDEO);
  87.                 Console.Put(ASCII.BEL);
  88.             end if;                            
  89.     
  90.             Equal_signs := INTEGER(arg(i).value / Range_per_equal + 1.0);
  91.             -- may use Exception here if out of range on Equal_signs    
  92.  
  93.             -- SPACECRAFT_SECTION_IO.Put(i);
  94.             if i = BRIDGE then Console.Put("BRIDGE           ");end if;
  95.             if i = AUXILIARY_BRIDGE then Console.Put("AUXILARY BRIDGE  ");end if;
  96.             if i = CREW_QUARTERS then Console.Put("CREW_QUARTERS    ");end if;
  97.             if i = GALLEY then Console.Put("GALLEY           ");end if;
  98.             if i = LAB1 then Console.Put("LAB 1            ");end if;
  99.             if i = LAB2 then Console.Put("LAB 2            ");end if;
  100.             if i = LAB3 then Console.Put("LAB 3            ");end if;
  101.             if i = AIRLOCK1 then Console.Put("AIRLOCK 1        ");end if;
  102.             if i = AIRLOCK2 then Console.Put("AIRLOCK 2        ");end if;
  103.             if i = EXPERIMENT_BAY then Console.Put("EXPERIMENT BAY   ");end if;
  104.  
  105.             for j in 1 .. Equal_signs loop 
  106.                 Console.Put('=');
  107.             end loop;
  108.             for j in 1 .. 50-Equal_signs loop
  109.                 Console.Put(' ');
  110.             end loop;
  111.             Console.Put(FLOAT(arg(i).value),4,2,OUTPUT_FULL_NUMBER,'*');
  112.  
  113.             Console.New_Line;
  114.         end loop;
  115.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);    
  116.     end Display;
  117.  
  118.     procedure Display(arg: in TEMPERATURE_ARRAY) is
  119.     Range_per_equal: constant TEMPERATURE := 5.0;
  120.     Equal_signs : INTEGER;
  121.     package SPACECRAFT_SECTION_IO is new ENUMERATION_IO(SPACECRAFT_SECTION);
  122.     use SPACECRAFT_SECTION_IO;
  123.  
  124.     begin
  125.         Console.Set_Terminal (VT100);
  126.         Console.Enable_Output;
  127.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  128.         for j in 1 .. 50 loop
  129.             Console.Put('*');
  130.         end loop;
  131.         Console.New_Line;
  132.         Console.Put_Line("Temperature      min                    max");
  133.         Console.Put_Line("Degrees F         |                      |");
  134.         Console.Put_Line("                  V                      V");
  135.  
  136.         for i in SPACECRAFT_SECTION'FIRST .. SPACECRAFT_SECTION'LAST loop
  137.  
  138.             if arg(i).in_range then
  139.                 Console.Set_Rendition(ALL_ATTRIBUTES_OFF);
  140.             else
  141.                 Console.Set_Rendition(REVERSE_VIDEO);
  142.                 Console.Put(ASCII.BEL);
  143.             end if;                            
  144.     
  145.             Equal_signs := INTEGER(arg(i).value / Range_per_equal + 1.0);
  146.             -- may use Exception here if out of range on Equal_signs    
  147.             if i = BRIDGE then Console.Put("BRIDGE           ");end if;
  148.             if i = AUXILIARY_BRIDGE then Console.Put("AUXILIARY BRIDGE ");end if;
  149.             if i = CREW_QUARTERS then Console.Put("CREW_QUARTERS    ");end if;
  150.             if i = GALLEY then Console.Put("GALLEY           ");end if;
  151.             if i = LAB1 then Console.Put("LAB 1            ");end if;
  152.             if i = LAB2 then Console.Put("LAB 2            ");end if;
  153.             if i = LAB3 then Console.Put("LAB 3            ");end if;
  154.             if i = AIRLOCK1 then Console.Put("AIRLOCK 1        ");end if;
  155.             if i = AIRLOCK2 then Console.Put("AIRLOCK 2        ");end if;
  156.             if i = EXPERIMENT_BAY then Console.Put("EXPERIMENT BAY   ");end if;
  157.  
  158.             for j in 1 .. Equal_signs loop 
  159.                 Console.Put('=');
  160.             end loop;
  161.             for j in 1 .. 50-Equal_signs loop
  162.                 Console.Put(' ');
  163.             end loop;
  164.             Console.Put(FLOAT(arg(i).value),4,2,OUTPUT_FULL_NUMBER,'*');
  165.  
  166.             Console.New_Line;
  167.         end loop;
  168.         Console.Set_Rendition(ALL_ATTRIBUTES_OFF);    
  169.     end Display;
  170.  
  171. end CRT_Output; 
  172.